#pragma once
#include "ISimpleHashEntry.h"
#include "CWeakRefHashKey.h"

class CDependencyObject;

class CWeakRef :
	public ISimpleHashEntry,
	public CWeakRefHashKey
{
private: 
	virtual ~CWeakRef();
public: 
	static void * operator new(unsigned int __formal, void * pBuffer);
private: 
	static void * operator new(unsigned int);
public: 
	CWeakRef(CDependencyObject * pTargetObject, XFixedSizeAllocator * pAllocator);
	virtual XUINT32 AddRef();
	virtual XUINT32 Release();
	virtual XUINT32 GetHash();
	virtual XINT32 EqualKeys(const struct ISimpleHashKey * pOther);
	virtual void OnRemove();
	long RegisterListener(struct IWeakRefListener * pListener);
	long UnregisterListener(struct IWeakRefListener * pListener);
private: 
	int m_nRefCount;
	xvector<IWeakRefListener *> * m_pListeners;
	XFixedSizeAllocator * m_pAllocator;
};

